<?php
/**
 * Created by PhpStorm.
 * User: iceberg
 * Date: 2019-01-28
 * Time: 15:22
 */

namespace app\base\controller;

use think\Controller;
use app\service\DataService;
class Data extends Controller
{
    //分类服务
    private $dataService;

    //初始化方法
    public function initialize()
    {
        $this->dataService = new DataService();
    }

    //显示列表
    public function index()
    {
        $this->assign('count', $this->dataService->count());
        $dataSet = $this->dataService->page();
//        echo 'pre';
//        var_dump($dataSet);
//        die;
        $this->assign('list', $dataSet);
        return $this->fetch();
    }

    //导出资料
    public function export()
    {
        return $this->dataService->export();
    }

    //删除
    public function delete($id)
    {
        return $this->dataService->delete($id);
    }

    //编辑(查看)
    public function edit($id)
    {
        $this->assign('info', $this->dataService->edit($id));
        return $this->fetch();
    }
}